package cn.zhentao.service.impl;

import cn.zhentao.mapper.UsersMapper;
import cn.zhentao.pojo.QueryUser;
import cn.zhentao.pojo.Users;
import cn.zhentao.service.IUsersService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 用户信息表 服务实现类
 * </p>
 *
 * @author mp
 * @since 2025-06-16
 */
@Service
public class UsersServiceImpl extends ServiceImpl<UsersMapper, Users> implements IUsersService {

    @Autowired
    UsersMapper usersMapper;

    @Override
    public Page<Users> findPage(QueryUser queryUser) {
        Page<Users> page = new Page<>(queryUser.getCurrent(), queryUser.getSize());
        QueryWrapper<Users>wrapper=new QueryWrapper<>();
        wrapper.like(queryUser.getUsername()!=null,"username",queryUser.getUsername());
        wrapper.like(queryUser.getPhone()!=null,"phone",queryUser.getPhone());
        wrapper.between(queryUser.getStartRegisterTime()!=null,"created_at",queryUser.getStartRegisterTime(),queryUser.getEndRegisterTime());
        usersMapper.selectPage(page, wrapper);
        List<Users> list = page.getRecords();
        return page;
    }


}
